//
//  SettingTableViewCell.m
//  HWZB
//
//  Created by 许成雄 on 2017/4/23.
//  Copyright © 2017年 wonders. All rights reserved.
//

#import "SettingTableViewCell.h"

@interface SettingTableViewCell()

@property (strong, nonatomic) UIImageView *iconImageView;
@property (strong, nonatomic) UILabel *titleLabel;
@property (strong, nonatomic) UILabel *descLabel;

@end

@implementation SettingTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self) {
        self.iconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(TRANS_VALUE(14.0f), TRANS_VALUE(14.0f), TRANS_VALUE(16.0f), TRANS_VALUE(16.0f))];
        self.iconImageView.contentMode = UIViewContentModeScaleAspectFit;
        [self.contentView addSubview:self.iconImageView];
        
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(TRANS_VALUE(40.0f), TRANS_VALUE(7.0f), TRANS_VALUE(200.0f), TRANS_VALUE(30.0f))];
        self.titleLabel.font = [UIFont systemFontOfSize:TRANS_VALUE(13.0f)];
        self.titleLabel.textColor = I_COLOR_BLACK;
        [self.contentView addSubview:self.titleLabel];
        
        self.descLabel = [[UILabel alloc] initWithFrame:CGRectMake(TRANS_VALUE(250.0f), TRANS_VALUE(7.0f), TRANS_VALUE(50.0f), TRANS_VALUE(30.0f))];
        self.descLabel.font = [UIFont systemFontOfSize:TRANS_VALUE(13.0f)];
        self.descLabel.textColor = I_COLOR_BLACK;
        self.descLabel.textAlignment = NSTextAlignmentRight;
        [self.contentView addSubview:self.descLabel];
    }
    self.contentView.backgroundColor = I_COLOR_WHITE;
    
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    // Configure the view for the selected state
}

- (void)setSettingItem:(SettingItemInfo *)settingItem {
    _settingItem = settingItem;
    if(_settingItem) {
        self.iconImageView.image = [UIImage imageNamed:_settingItem.icon];
        self.titleLabel.text = _settingItem.title;
    }
}

- (void)showAppVersion:(NSString *)version {
    if(version) {
        self.descLabel.hidden = NO;
        self.descLabel.text = [NSString stringWithFormat:@"V%@", version];
    } else {
        self.descLabel.hidden = YES;
        self.descLabel.text = @"";
    }
}



@end
